package Text11;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    //日期采用的格式非常不统一，有采用年/月/日的，有采用月/日/年的，还有采用日/月/年的。
    static int[] days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    public static void main(String[] args) throws IOException {
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        String[] s = read.readLine().split("/");
        Date[] dates = new Date[3];
        int a = Integer.parseInt(s[0]);
        int b = Integer.parseInt(s[1]);
        int c = Integer.parseInt(s[2]);
        int y = 0, m = 0, d = 0, k = 0;
        /*年/月/日*/
        if (a >= 60) {
            y = 1900 + a;
        } else {
            y = 2000 + a;
        }
        m = b;
        d = c;
        if (check(y, m, d)) {
            dates[k++] = new Date(y, m, d);
        }
        /*月/日/年*/
        if (c >= 60) {
            y = 1900 + c;
        } else {
            y = 2000 + c;
        }
        m = a;
        d = b;
        if (check(y, m, d)) {
            dates[k++] = new Date(y, m, d);
        }
        /*日/月/年*/
        if (c >= 60) {
            y = 1900 + c;
        } else {
            y = 2000 + c;
        }
        m = b;
        d = a;
        if (check(y, m, d)) {
            dates[k++] = new Date(y, m, d);
        }
        Arrays.sort(dates, 0, k);
        for (int i = 0; i < k; i++) {
            if (i == k - 1 || dates[i].y != dates[i + 1].y || dates[i].m != dates[i + 1].m || dates[i].d != dates[i + 1].d) {
                System.out.printf("%d-%02d-%02d", dates[i].y, dates[i].m, dates[i].d);
                System.out.println();
            }
        }
    }

    private static boolean check(int y, int m, int d) {
        if (m == 0 || m > 12) {
            return false;
        }
        if (d == 0 || m != 2 && d > days[m]) {
            return false;
        }
        if (m == 2) {
            int leap = 0;
            if (y % 400 == 0 || y % 100 != 0 && y % 4 == 0) {
                leap++;
            }
            if (d > days[m] + leap) {
                return false;
            }
        }
        return true;
    }
}

class Date implements Comparable<Date> {
    int y, m, d;

    public Date(int y, int m, int d) {
        this.y = y;
        this.m = m;
        this.d = d;
    }

    @Override
    public int compareTo(Date o) {
        if (o.y != this.y) {
            Integer.compare(o.y, this.y);
        }
        if (o.m != this.m) {
            Integer.compare(o.m, this.m);
        }
        return Integer.compare(o.d, this.d);
    }
}